package csvs

import "MyWuXiaGame/server/src/utils"

type ConfigNpc struct {
	NpcId   int    `json:"NpcId"`
	NpcName string `json:"NpcName"`
	NpcMapId  int `json:"NpcMapId"`
	AppearDescribe string `json:"AppearDescribe"`
	StrengthDescribe string `json:"StrengthDescribe"`
	ConcreteDescribe string `json:"ConcreteDescribe"`
	Ability  string	`json:"Ability"`
	JobAttr  TGrowthLineJobAttr
}

type ConfigNpcDialog struct {
	NpcId   int    `json:"NpcId"`
	NpcName string `json:"NpcName"`
	Weight  int    `json:"Weight"`
	Dialog  string `json:"Dialog"`
}

type ConfigNpcSkill struct {
	NpcId	int    `json:"NpcId"`
	NpcName	string `json:"NpcName"`
	Weight	int    `json:"Weight"`
	SkillID	int    `json:"SkillID"`
	SkillName	string `json:"SkillName"`
	SkillLv	int    `json:"SkillLv"`
}

var (
	ConfigNpcSlice		 []*ConfigNpc
	ConfigNpcMap         map[int]*ConfigNpc
	ConfigNpcDialogSlice []*ConfigNpcDialog
	ConfigNpcSkillSlice	 []*ConfigNpcSkill
)

func init() {
	utils.GetCsvUtilMgr().LoadCsv("Npc", &ConfigNpcSlice)

	ConfigNpcMap = make(map[int]*ConfigNpc)
	for _, v := range ConfigNpcSlice {
		ConfigNpcMap[v.NpcId] = v
	}

	utils.GetCsvUtilMgr().LoadCsv("NpcDialog", &ConfigNpcDialogSlice)
	utils.GetCsvUtilMgr().LoadCsv("NpcSkill", &ConfigNpcSkillSlice)
	return
}

func GetNpcConfig(NpcId int) *ConfigNpc {
	return ConfigNpcMap[NpcId]
}

func GetNpcName(NpcId int) string {
	config := GetNpcConfig(NpcId)
	if config != nil {
		return config.NpcName
	}

	return ""
}